import Vue from "vue"
import Vuex from "vuex"

Vue.use(Vuex)

// Vuex 数据持久化  存储localStorage 
// 引入插件
import createPersistedState from "vuex-persistedstate";

const store = new Vuex.Store({
    plugins: [createPersistedState()],
    modules: {

    },
    state: {
        count: 1090,
        username: 'zkl',
        cartNum: 8,
        userInfo: null,
        city: null,  // 城市信息 
        cityList: [],
        cinemaList: [], // 全城的电影院
    },
    mutations: {
        changeCinemaList(state, payload) {
            state.cinemaList = payload
        },
        changeCityList(state, payload) {
            state.cityList = payload
        },
        changeCity(state, payload) {
            state.city = payload
        },
        changeCount(state, payload) {
            state.count += payload
        },
        changeUserInfo(state, payload) {
            state.userInfo = payload
        }
    },
    getters: {

    },
    actions: {

    }
})

export default store;